package com.tegtech.api.system.domain.tree;

import java.util.stream.Collectors;

import com.tegtech.common.domain.TreeSelect;
import com.tegtech.module.auth.domain.SysDept;
import com.tegtech.module.auth.domain.SysMenu;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class SysTreeSelect extends TreeSelect {

	private static final long serialVersionUID = 1L;

	public SysTreeSelect(SysDept dept) {
		this.id = dept.getDeptId();
		this.label = dept.getDeptName();
		this.children = dept.getChildren().stream().map(SysTreeSelect::new).collect(Collectors.toList());
	}

	public SysTreeSelect(SysMenu menu) {
		this.id = menu.getMenuId();
		this.label = menu.getMenuName();
		this.children = menu.getChildren().stream().map(SysTreeSelect::new).collect(Collectors.toList());
	}

}
